package LanQiao._15JavaB;

import java.util.Scanner;

public class _5 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        double p = sc.nextDouble();

        int k = 2;
        int ret = 1;
        double min = N;
        for (; k <= N; k++) {
            if (N % k == 0) {
                double helper = helper(N, p, k);
                if (min > helper){
                    min = helper;
                    ret = k;
                }else if (min == helper){
                    ret = ret >= k ? k : ret;
                }
            }
        }
        System.out.println(ret);
        sc.close();

    }

    public static double helper(int N,double p,int k){
        double count = 0;
        double pow = Math.pow(1 - p, k);
        count = N / k + (1 - pow) * N;
        return count;
    }
}
